using System;
using System.Windows.Forms;

using FreeFlow.Administration;

namespace FreeFlowAdministrator
{
	/// <summary>
	/// Summary description for AuthenticationScriptAdaptor.
	/// </summary>
	public class AuthenticationScriptAdaptor : Adaptor, IDeletable
	{
    private AuthenticationScript script;
		public AuthenticationScriptAdaptor(AuthenticationScript script)
		{
			this.script = script;
		}

    public override string Text
    {
      get
      {
        if (script.IsGuestScript)
          return script.Name + " (guest)";
        else
          return script.Name + " (standard)";
      }
    }

    public override object Object
    {
      get
      {
        return script;
      }
    }

    public override int ImageIndex
    {
      get
      {
        return 31;
      }
    }

    public override Control GetRenderer()
    {
      AuthenticationScriptControl scriptControl = new AuthenticationScriptControl();
      scriptControl.LoadScript(script);
      scriptControl.ItemDeleted += new EventHandler(TriggerItemDeleted);
      return scriptControl;
    }
    #region IDeletable Members

    public void Delete()
    {
      script.Delete();
    }

    #endregion
  }
}
